USE CAFEDB
GO

-----------------------------UPDATE PROCEDURE -----------------------------
--AREA
CREATE PROC UPDATEAREABYAREAID(@AREAID varchar(20),@AREANAME nvarchar(50))
AS
	BEGIN
		UPDATE [CAFEDB].[dbo].[AREA]
		 SET AREANAME = @AREANAME
		WHERE AREAID=@AREAID
	END
GO
--DEPARTMENT
CREATE PROC UPDATEDEPARTMENTBYDEPARTMENTID(@DEPARTMENTID varchar(20),@DEPARTMENTNAME nvarchar(100))
AS
	BEGIN
		UPDATE [CAFEDB].[dbo].[DEPARTMENT]
   SET 
      [DEPARTMENTNAME] = @DEPARTMENTNAME
 WHERE DEPARTMENTID=@DEPARTMENTID
	END
GO
--DETAIL_GROUPUSER_ROLE

--EMPLOYER
CREATE   PROC  UPDATEEMPLOYERBYEMPLOYERID(@EMPLOYERID int
      ,@FIRSTNAME nvarchar(50)
      ,@MIDDLENAME nvarchar(50)
      ,@LASTNAME nvarchar(50)
      ,@FULLNAME nvarchar(150)
      ,@DOB datetime
      ,@IDCARD varchar(9)
      ,@ADDRESS nvarchar(100)
      ,@DATEWORK datetime
      ,@DEPARTMENTID varchar(20))
AS
	BEGIN
		UPDATE [CAFEDB].[dbo].[EMPLOYER]
   SET 
      [FIRSTNAME] = @FIRSTNAME
      ,[MIDDLENAME] = @MIDDLENAME
      ,[LASTNAME] = @LASTNAME
      ,[FULLNAME] = @FULLNAME
      ,[DOB] = @DOB
      ,[IDCARD] = @IDCARD
      ,[ADDRESS] = @ADDRESS
      ,[DATEWORK] = @DATEWORK
      ,[DEPARTMENTID] = @DEPARTMENTID
 WHERE [EMPLOYERID] = @EMPLOYERID
	END
GO
--EXPORT

--EXPORTDETAIL

--GROUPUSER
CREATE PROC UPDATEGROUPUSERBYGROUPUSERID(@GROUPUSERCODE INT
			,@GROUPUSERNAME nvarchar(100)
			,@GROUPUSERDESCRIPTION nvarchar(100) 
			,@USERUPDATE varchar(30))
AS
	BEGIN
	UPDATE [CAFEDB].[dbo].[GROUPUSER]
	SET 
	
	[GROUPUSERNAME] = @GROUPUSERNAME
      ,[GROUPUSERDESCRIPTION] = @GROUPUSERDESCRIPTION
      ,[USERUPDATE] = @USERUPDATE
      ,[LASTUPDATE] = GETDATE()
 WHERE GROUPUSERCODE=@GROUPUSERCODE
	END
GO
--IMPORT

--IMPORTDETAIL

--ITEM
CREATE  PROC UPDATEITEMBYITEMID(@ITEMID INT
	  ,@ITEMNAME nvarchar(50)
      ,@ITEMTYPEID int
      ,@ISDRINK bit
      ,@PRICE float
      ,@SHORTCUT VARCHAR(50))
AS
	BEGIN
		UPDATE [CAFEDB].[dbo].[ITEM]
   SET 
      [ITEMNAME] = @ITEMNAME
      ,[ITEMTYPEID] = @ITEMTYPEID
      ,[ISDRINK] = @ISDRINK
      ,[PRICE] = @PRICE
      ,[SHORTCUT]=@SHORTCUT
 WHERE [ITEMID] = @ITEMID
	END
GO
--ITEMTYPE
CREATE PROC UPDATEITEMTYPEBYITEMTYPEID( @ITEMTYPEID int,@ITEMTYPENAME nvarchar(50))
AS
	BEGIN
		UPDATE [CAFEDB].[dbo].[ITEMTYPE]
   SET 
      [ITEMTYPENAME] = @ITEMTYPENAME
 WHERE [ITEMTYPEID] = @ITEMTYPEID
	END
GO
--MATERIAL
CREATE PROC UPDATEMATERIALBYMATERIALID(@MATERIALID int
      ,@MATERIALNAME nvarchar(50)
      ,@QUANTITY float
      ,@UNITID int)
AS
	BEGIN
		UPDATE [CAFEDB].[dbo].[MATERIAL]
   SET 
       [MATERIALNAME] = @MATERIALNAME
      ,[QUANTITY] = @QUANTITY
      ,[UNITID] = @UNITID
 WHERE [MATERIALID] = @MATERIALID
	END
GO
--GROUP ROLE
CREATE  PROC UPDATEGROUPROLEBYGROUPROLEID(@GROUPROLECODE VARCHAR(50)
      ,@GROUPROLENAME nvarchar(100)
      ,@USERUPDATE varchar(30))
AS 
	BEGIN
		UPDATE [CAFEDB].[dbo].[GROUPROLE]
   SET 
       
      [GROUPROLENAME] = @GROUPROLENAME
      ,[USERUPDATE] = @USERUPDATE
      ,[LASTUPDATE] = GETDATE()
 WHERE [GROUPROLECODE] = @GROUPROLECODE
	END
GO
--ROLE
CREATE PROC UPDATEROLEBYROLEID(@ROLECODE varchar(50)
      ,@ROLENAME nvarchar(100)
      ,@GROUPROLECODE varchar(50)
      ,@USERUPDATE varchar(30))
AS 
	BEGIN
		UPDATE [CAFEDB].[dbo].[ROLE]
   SET 
       [ROLENAME] = @ROLENAME
      ,[GROUPROLECODE] = @GROUPROLECODE
      ,[USERUPDATE] = @USERUPDATE
      ,[LASTUPDATE] = GETDATE()
 WHERE [ROLECODE] = @ROLECODE
	END
GO
--TABLE
CREATE PROC UPDATETABLEBYTABLEID(@TABLEID INT
      ,@TABLENAME nvarchar(50)
      ,@AREAID varchar(20))
AS
	BEGIN
		UPDATE [CAFEDB].[dbo].[TABLE]
   SET 
       [TABLENAME] = @TABLENAME
      ,[AREAID] = @AREAID
 WHERE [TABLEID] = @TABLEID
	END
GO
--UNIT
CREATE PROC UPDATEUNITBYUNITID(@UNITID int
      ,@UNITNAME nvarchar(50))
AS
	BEGIN
		UPDATE [CAFEDB].[dbo].[UNIT]
   SET 
      [UNITNAME] = @UNITNAME
 WHERE [UNITID] = @UNITID
	END
GO
--USERACCOUNT
CREATE  PROC UPDATEUSERACOUNTBYID(@USERNAME varchar(30)
      ,@PASSWORD varchar(32)
      ,@FIRSTNAME nvarchar(50)
      ,@MIDDLENAME nvarchar(50)
      ,@LASTNAME nvarchar(50)
      ,@FULLNAME nvarchar(150)
      ,@DOB datetime
      ,@EMAIL varchar(100)
      ,@IDCARD varchar(20)
      ,@ISADMIN bit
      ,@MOBILEPHONE varchar(20)
      ,@HOMEPHONE varchar(20)
      ,@GROUPUSERCODE int
      ,@EMPLOYERID varchar(20))
AS
	BEGIN
		UPDATE [CAFEDB].[dbo].[USERACCOUNT]
   SET 
      [FIRSTNAME] = @FIRSTNAME
      ,[MIDDLENAME] = @MIDDLENAME
      ,[LASTNAME] = @LASTNAME
      ,[FULLNAME] = @FULLNAME
      ,[DOB] = @DOB
      ,[EMAIL] = @EMAIL
      ,[IDCARD] = @IDCARD
      ,[DATECREATE] = getdate()
      ,[LASTUPDATE] = getdate()
      ,[ISADMIN] = @ISADMIN
      ,[MOBILEPHONE] = @MOBILEPHONE
      ,[HOMEPHONE] = @HOMEPHONE
      ,[GROUPUSERCODE] = @GROUPUSERCODE
      ,[EMPLOYERID] = @EMPLOYERID
 WHERE [USERNAME] = @USERNAME
      
	END
GO
--WAGE
CREATE PROC UPDATEWAREBYWAGEID(@WAGEID varchar(20)
      ,@WAGENAME nvarchar(50)
      ,@PRICE float)

AS
	BEGIN
		UPDATE [CAFEDB].[dbo].[WAGE]
   SET 
      [WAGENAME] = @WAGENAME
      ,[PRICE] = @PRICE

 WHERE [WAGEID] = @WAGEID
	END
GO	